/**
 *  @file BufferedReader.h
 */
#ifndef _BUFFEREDREADER_H_
#define _BUFFEREDREADER_H_

#include "Reader.h"

namespace cppflib
{

// forward declaration
namespace collections { class CircularBuffer; }

namespace io
{

/**
 *  A reader which can buffer characters read from another reader
 */
class _DLLAPI BufferedReader : public Reader
{
private:
    ptr_t readPos;  ///< readPos is a value between 0 and pCirBuf->GetValidLength() (inclusive)
    Reader *pOrgReader;
    collections::CircularBuffer *pCirBuf;

private:
	BufferedReader(void);

public:
    BufferedReader(Reader *pReader, sz_t bufferSize);
    explicit BufferedReader(Reader *pReader);
	virtual ~BufferedReader(void);

    virtual void Close();
    virtual int Read(collections::ArrayWChar &buffer);
    virtual int Read(collections::ArrayWChar &buffer, int offset, int count);
    virtual int Read();
    virtual i64_t Skip(i64_t charCount);
    virtual sz_t CanReadNoBlocking();
};


} // end of namespace io

} // end of namespace cppflib

#endif
